

<script setup lang="ts">
import ChartsLine from "@/Components/ChartsLine.vue";
import type {typeChartsLineData} from "@/store/dataType";
import {ref, toRaw} from "vue";
import {typeUserChat} from "@/store/dataType";
import {findAllUserChatByAccountName} from "@/Network/chatApi";
import {anaDataDate, anaDataTime} from "@/utils/anaData";
import ChartsPie from "@/Components/ChartsPie.vue";





// console.log(lineData.value)




let chatData = ref<typeUserChat[]>()
let dateNameList = ref<string[]>([])
let dateValueList = ref<number[]>([])
findAllUserChatByAccountName(localStorage.getItem("accountName")).then(res=>{
  chatData.value = res.data
  // console.log(chatData.value)
  let timeData = anaDataTime(chatData.value,"createTime",3)
  let dateData = anaDataDate(chatData.value,"createTime")

  for(const ele of dateData){
    dateNameList.value.push(ele.name)
    dateValueList.value.push(ele.value)
  }
  // xAxisData
  localStorage.setItem("dateNameList",JSON.stringify(dateNameList.value))
  // seriesData
  localStorage.setItem("dateValueList",JSON.stringify(dateValueList.value))
})


let chartsLineData=ref({
  //通过传key的名字，来告诉子组件应该 本地获取（localStorage）什么key
  titleText:"近7日的问答趋势",
  xAxisData:"dateNameList",
  seriesData:"dateValueList"
})

</script>

<template>
  <div class="h-50% w-50% flex justify-center items-center">
    <charts-line :chartsLineData="chartsLineData"
                 class="w-full h-full"
    >
    </charts-line>

  </div>
</template>

<style scoped>
/* 添加一些CSS样式来美化图表容器（可选） */
</style>
